import { useModel } from "umi";

const useCheckPositionName = () => {
    const { graphqlFetch } = useModel("global");

    const checkPositionName = async (opName) => {
        let res = await graphqlFetch({
            query: `query MyQuery($opName: String!) { a: allOrganizationPositions(condition: { opName: $opName }) { totalCount } }`,
            variables: { opName },
        });
        return res ? res.a.totalCount : null;
    };

    return { checkPositionName };
};

export default useCheckPositionName;
